<template>
  <div>
    <el-table :data="results" class="resultsTable" stripe>
      <el-table-column prop="personId" label="ID/Code"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="age" label="年龄"></el-table-column>

      <el-table-column label="性别" :formatter="maleFormat"> </el-table-column>

      <el-table-column width="180px" fixed="left">
        <template slot-scope="props">
          <el-button
            class="el-button--mini"
            type="warning"
            icon="el-icon-edit"
            @click="openById(props.row.personId)"
            >编辑</el-button
          >
          <el-button
            class="el-button--mini"
            type="danger"
            icon="el-icon-edit"
            @click="delete(props.row.personId)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// import New from './components/New.vue';
export default {
  name: "Fifth",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      sampleD: "value",
      searchForm: {
        pageNum: 1,
        pageSize: 5,
        queryCondition: {},
      },
      total: null,
      /**
       * Person {
    "personId": 1,
    "name": "王七",
    "age": 10,
    "male": true
         },
       * */
      results: [
        {
          personId: 1,
          name: "王七",
          age: 10,
          male: true,
        },
      ],
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {
    this.queryByCondition();
  },
  methods: {
    sampleM() {},
    queryByCondition(pageNum) {
      if (pageNum) this.searchForm.pageNum = pageNum;
      this.$http({
        method: "post",
        url: "/queryPersons",
        data: this.searchForm,
      }).then(
        (res) => {
          // this.total = res.data.total;
          this.results = res.data;
        },
        (error) => {
          this.$message.warning("query mistake：" + error.response.status);
        }
      );
    },
    maleFormat(row) {
      return row.male ? "男" : "女";
    },
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<style scoped>
/*<style lang='scss' scoped>*/
</style>
